<%@ include file="/WEB-INF/work/start.jspf"%><html lang="zh-hans">
<head>
<%@ include file="/WEB-INF/jspf/meta.jspf"%>
<title>任务详情</title>
<%@ include file="/WEB-INF/work/css.jspf"%>
<style type="text/css">
.pure-table{
	margin-top:10px;
}
.filter-bar{
	margin-top:5px;
	text-align:center;
}
@media screen and (max-width:600px){
	.table-response.pure-table td:before{
		content: attr(data-label);
		float:left;
		text-transform: uppercase;
		font-weight:bold;
	}
	.table-response.pure-table thead{
		display:none;
	}
	.table-response.pure-table tr{
		display:block;
		margin-bottom:10px;
		border-bottom:2px solid #ddd;
	}
	.table-response.pure-table td{
		display:block;
		text-align:right;
	}
}
.pure-form select{
	height:2.4em;
}
.pure-button-primary{
	margin-top: 18px;
    font-size: 110%;
}
</style>
</head>
<body>
<fmt:parseNumber var="id" integerOnly="true" type="number" value="${param.id}" />

		<sql:query var="items" dataSource="${ work }">
select a.*
	,case 
		when a.status = 'progress'
			then 1
		when a.status = 'new'
			then 2
		when a.status = 'defer'
			then 3
		end as sort_order
	,b.name as project_name
	,c.username as created_by
	,d.username as assigned_to
from simpletask_task a
INNER JOIN simpletask_project b on a.project_id = b.id
inner join auth_user c on c.id=a.created_by_id
inner join auth_user d on d.id=a.assigned_to_id
where 1=1 
		<c:if test="${empty status}">
			and (a.status = 'new'
		or a.status = 'progress'
		or a.status = 'defer')
		</c:if>
		<c:if test="${! empty status}">
			and a.status=?
		</c:if>
		<c:if test="${! empty project}">
			and a.project_id=?
		</c:if>
		<c:if test="${! empty assignedTo}">
			and a.assigned_to_id=?
		</c:if>
		<c:if test="${! empty createdBy}">
			and a.created_by_id=?
		</c:if>	
order by sort_order asc
	,a.id desc
		<c:if test="${! empty status}">
			<sql:param value="${status}"></sql:param>
		</c:if>
		<c:if test="${! empty project}">
			<sql:param value="${project}"></sql:param>
		</c:if>
		<c:if test="${! empty assignedTo}">
			<sql:param value="${assignedTo}"></sql:param>
		</c:if>
		<c:if test="${! empty createdBy}">
			<sql:param value="${createdBy}"></sql:param>
		</c:if>	
		</sql:query>
		<c:forEach var="item" items="${items.rows}" varStatus="status">
			<tr class="task-${item.status}">
			<td data-label="ID">${item.id}</td>
			<td data-label="项目名称">[${item.project_name}]${item.title}</td>
			<td data-label="状态">${allStatus[item.status]}</td>
			<td data-label="创建人">${item.created_by}</td>
			<td data-label="分配给">${item.assigned_to}</td>
			<!--<td>{{item.created_at|date:"Y-m-d"}}</td>-->
			<td data-label="最后期限">${item.due_at}</td>
			<!--<td>{{item.done_at|date:"Y-m-d"}}</td>-->
			</tr>
		</c:forEach>
<%@ include file="/WEB-INF/jspf/js.jspf"%>
<script type="text/javascript">
/*
 var queryString = {},
	 url='<%=request.getRequestURI()%>';
if (location.search) {
   var qa = location.search.substring(1).split('&');
   for (var i = 0, t = qa.length; i < t; i++) {
	   var item=qa[i].split('=');
	   queryString[item[0]] = item[1]||'';
   }
}


$("select").change(function(){
	var self=$(this),
		q={};
	q[self.attr('id')]=self.val();
	location.href=url+'?'+$.param($.extend(queryString,q));
});
*/
</script>
</body>
</html>